//form validation
function pageInit(){
	//页面初始化
	var value = $("#weightType").val();
	if(value == ""|| value == "SR"){
		$("#weightB")[0].style.display="none";
		$("#weightText")[0].style.display="none";
		$("#weightText").attr("readonly","readonly");
		$("#weightBText")[0].style.display="none";
		$("#weightEText")[0].style.display="none";
		$("#weightB").val("");
		$("#weightText").val("");
		$("#weightBText").val("");
		$("#weightEText").val("");
	}else if(value == "NOTRANGE"){
		$("#weightB")[0].style.display="";
		$("#weightText")[0].style.display="";
		$("#weightBText")[0].style.display="none";
		$("#weightEText")[0].style.display="none";
		$("#weightBText").val("");
		$("#weightEText").val("");
	}else if(value == "RANGE"){
		$("#weightBText")[0].style.display="";
		$("#weightEText")[0].style.display="";
		$("#weightB")[0].style.display="none";
		$("#weightText")[0].style.display="none";
		$("#weightText").attr("readonly","readonly");
		$("#weightB").val("");
		$("#weightText").val("");
	}else{
		$("#weightB")[0].style.display="none";
		$("#weightText")[0].style.display="none";
		$("#weightText").attr("readonly","readonly");
		$("#weightBText")[0].style.display="none";
		$("#weightEText")[0].style.display="none";
		$("#weightB").val("");
		$("#weightText").val("");
		$("#weightBText").val("");
		$("#weightEText").val("");
	}
	var value = $("#amountType").val();
	if(value == "" || value == "SR"){
		$("#amountB")[0].style.display="none";
		$("#amountText")[0].style.display="none";
		$("#amountText").attr("readonly","readonly");
		$("#amountBText")[0].style.display="none";
		$("#amountEText")[0].style.display="none";
		$("#amountB").val("");
		$("#amountText").val("");
		$("#amountBText").val("");
		$("#amountEText").val("");
	}else if(value == "NOTRANGE"){
		$("#amountB")[0].style.display="";
		$("#amountText")[0].style.display="";
		$("#amountBText")[0].style.display="none";
		$("#amountEText")[0].style.display="none";
		$("#amountBText").val("");
		$("#amountEText").val("");
	}else if(value == "RANGE"){
		$("#amountBText")[0].style.display="";
		$("#amountEText")[0].style.display="";
		$("#amountB")[0].style.display="none";
		$("#amountText")[0].style.display="none";
		$("#amountText").attr("readonly","readonly");
		$("#amountB").val("");
		$("#amountText").val("");
	}else{
		$("#amountB")[0].style.display="none";
		$("#amountText")[0].style.display="none";
		$("#amountText").attr("readonly","readonly");
		$("#amountBText")[0].style.display="none";
		$("#amountEText")[0].style.display="none";
		$("#amountB").val("");
		$("#amountText").val("");
		$("#amountBText").val("");
		$("#amountEText").val("");
	}
	
	var value = $("#buyCountType").val();
	if(value == "" || value == "SR"){
		$("#buyCountB")[0].style.display="none";
		$("#buyCountText")[0].style.display="none";
		$("#buyCountText").attr("readonly","readonly");
		$("#buyCountBText")[0].style.display="none";
		$("#buyCountEText")[0].style.display="none";
		$("#buyCountB").val("");
		$("#buyCountText").val("");
		$("#buyCountBText").val("");
		$("#buyCountEText").val("");
	}else if(value == "NOTRANGE"){
		$("#buyCountB")[0].style.display="";
		$("#buyCountText")[0].style.display="";
		$("#buyCountBText")[0].style.display="none";
		$("#buyCountEText")[0].style.display="none";
		$("#buyCountBText").val("");
		$("#buyCountEText").val("");
	}else if(value == "RANGE"){
		$("#buyCountBText")[0].style.display="";
		$("#buyCountEText")[0].style.display="";
		$("#buyCountB")[0].style.display="none";
		$("#buyCountText")[0].style.display="none";
		$("#buyCountText").attr("readonly","readonly");
		$("#buyCountB").val("");
		$("#buyCountText").val("");
	}else{
		$("#buyCountB")[0].style.display="none";
		$("#buyCountText")[0].style.display="none";
		$("#buyCountText").attr("readonly","readonly");
		$("#buyCountBText")[0].style.display="none";
		$("#buyCountEText")[0].style.display="none";
		$("#buyCountB").val("");
		$("#buyCountText").val("");
		$("#buyCountBText").val("");
		$("#buyCountEText").val("");
	}
}
$(function(){
	//查询form
	$("select#weightB").change(function(){
		var value = $("select#weightB").val();
		if(value == ""){
			$("#weightText").val("");
			$("#weightText").attr("readonly","readonly");
		}else{
			$("#weightText").removeAttr("readonly");
		}
	});
	$("select#weightE").change(function(){
		var value = $("select#weightE").val();
		if(value == ""){
			$("#weightEText").val("");
			$("#weightEText").attr("readonly","readonly");
		}else{
			$("#weightEText").removeAttr("readonly");
		}
	});
	$("select#amountB").change(function(){
		var value = $("select#amountB").val();
		if(value == ""){
			$("#amountText").val("");
			$("#amountText").attr("readonly","readonly");
		}else{
			$("#amountText").removeAttr("readonly");
		}
	});
	$("select#amountE").change(function(){
		var value = $("select#amountE").val();
		if(value == ""){
			$("#amountEText").val("");
			$("#amountEText").attr("readonly","readonly");
		}else{
			$("#amountEText").removeAttr("readonly");
		}
	});
	$("select#buyCountB").change(function(){
		var value = $("select#buyCountB").val();
		if(value == ""){
			$("#buyCountText").val("");
			$("#buyCountText").attr("readonly","readonly");
		}else{
			$("#buyCountText").removeAttr("readonly");
		}
	});
	$("select#buyCountE").change(function(){
		var value = $("select#buyCountE").val();
		if(value == ""){
			$("#buyCountEText").attr("");
			$("#buyCountEText").attr("readonly","readonly");
		}else{
			$("#buyCountEText").removeAttr("readonly");
		}
	});
	$("#weightType").change(function(){
		var value = $("#weightType").val();
		if(value == "" || value == "SR"){
			$("#weightB")[0].style.display="none";
			$("#weightText")[0].style.display="none";
			$("#weightText").attr("readonly","readonly");
			$("#weightBText")[0].style.display="none";
			$("#weightEText")[0].style.display="none";
			$("#weightB").val("");
			$("#weightText").val("");
			$("#weightBText").val("");
			$("#weightEText").val("");
		}else if(value == "NOTRANGE"){
			$("#weightB")[0].style.display="";
			$("#weightText")[0].style.display="";
			$("#weightBText")[0].style.display="none";
			$("#weightEText")[0].style.display="none";
			$("#weightBText").val("");
			$("#weightEText").val("");
		}else if(value == "RANGE"){
			$("#weightBText")[0].style.display="";
			$("#weightEText")[0].style.display="";
			$("#weightB")[0].style.display="none";
			$("#weightText")[0].style.display="none";
			$("#weightText").attr("readonly","readonly");
			$("#weightB").val("");
			$("#weightText").val("");
		}else{
			$("#weightB")[0].style.display="none";
			$("#weightText")[0].style.display="none";
			$("#weightText").attr("readonly","readonly");
			$("#weightBText")[0].style.display="none";
			$("#weightEText")[0].style.display="none";
			$("#weightB").val("");
			$("#weightText").val("");
			$("#weightBText").val("");
			$("#weightEText").val("");
		}
	});
	$("#amountType").change(function(){
		var value = $("#amountType").val();
		if(value == "" || value == "SR"){
			$("#amountB")[0].style.display="none";
			$("#amountText")[0].style.display="none";
			$("#amountText").attr("readonly","readonly");
			$("#amountBText")[0].style.display="none";
			$("#amountEText")[0].style.display="none";
			$("#amountB").val("");
			$("#amountText").val("");
			$("#amountBText").val("");
			$("#amountEText").val("");
		}else if(value == "NOTRANGE"){
			$("#amountB")[0].style.display="";
			$("#amountText")[0].style.display="";
			$("#amountBText")[0].style.display="none";
			$("#amountEText")[0].style.display="none";
			$("#amountBText").val("");
			$("#amountEText").val("");
		}else if(value == "RANGE"){
			$("#amountBText")[0].style.display="";
			$("#amountEText")[0].style.display="";
			$("#amountB")[0].style.display="none";
			$("#amountText")[0].style.display="none";
			$("#amountText").attr("readonly","readonly");
			$("#amountB").val("");
			$("#amountText").val("");
		}else{
			$("#amountB")[0].style.display="none";
			$("#amountText")[0].style.display="none";
			$("#amountText").attr("readonly","readonly");
			$("#amountBText")[0].style.display="none";
			$("#amountEText")[0].style.display="none";
			$("#amountB").val("");
			$("#amountText").val("");
			$("#amountBText").val("");
			$("#amountEText").val("");
		}
	});
	$("#buyCountType").change(function(){
		var value = $("#buyCountType").val();
		if(value == "" || value == "SR"){
			$("#buyCountB")[0].style.display="none";
			$("#buyCountText")[0].style.display="none";
			$("#buyCountText").attr("readonly","readonly");
			$("#buyCountBText")[0].style.display="none";
			$("#buyCountEText")[0].style.display="none";
			$("#buyCountB").val("");
			$("#buyCountText").val("");
			$("#buyCountBText").val("");
			$("#buyCountEText").val("");
		}else if(value == "NOTRANGE"){
			$("#buyCountB")[0].style.display="";
			$("#buyCountText")[0].style.display="";
			$("#buyCountBText")[0].style.display="none";
			$("#buyCountEText")[0].style.display="none";
			$("#buyCountBText").val("");
			$("#buyCountEText").val("");
		}else if(value == "RANGE"){
			$("#buyCountBText")[0].style.display="";
			$("#buyCountEText")[0].style.display="";
			$("#buyCountB")[0].style.display="none";
			$("#buyCountText")[0].style.display="none";
			$("#buyCountText").attr("readonly","readonly");
			$("#buyCountB").val("");
			$("#buyCountText").val("");
		}else{
			$("#buyCountB")[0].style.display="none";
			$("#buyCountText")[0].style.display="none";
			$("#buyCountText").attr("readonly","readonly");
			$("#buyCountBText")[0].style.display="none";
			$("#buyCountEText")[0].style.display="none";
			$("#buyCountB").val("");
			$("#buyCountText").val("");
			$("#buyCountBText").val("");
			$("#buyCountEText").val("");
		}
	});
	
	//新增form
	$("select#addWeightB").change(function(){
		var value = $("select#addWeightB").val();
		if(value == ""){
			$("input#addWeightText").val("");
			$("input#addWeightText").attr("readonly","readonly");
		}else{
			$("input#addWeightText").removeAttr("readonly");
		}
	});
	$("select#addWeightE").change(function(){
		var value = $("select#addWeightE").val();
		if(value == ""){
			$("#addWeightEText").val("");
			$("#addWeightEText").attr("readonly","readonly");
		}else{
			$("#addWeightEText").removeAttr("readonly");
		}
	});
	$("select#addAmountB").change(function(){
		var value = $("select#addAmountB").val();
		if(value == ""){
			$("#addAmountText").val("");
			$("#addAmountText").attr("readonly","readonly");
		}else{
			$("#addAmountText").removeAttr("readonly");
		}
	});
	$("select#addAmountE").change(function(){
		var value = $("select#addAmountE").val();
		if(value == ""){
			$("#addAmountEText").val("");
			$("#addAmountEText").attr("readonly","readonly");
		}else{
			$("#addAmountEText").removeAttr("readonly");
		}
	});
	$("select#addBuyCountB").change(function(){
		var value = $("select#addBuyCountB").val();
		if(value == ""){
			$("#addBuyCountText").val("");
			$("#addBuyCountText").attr("readonly","readonly");
		}else{
			$("#addBuyCountText").removeAttr("readonly");
		}
	});
	$("select#addBuyCountE").change(function(){
		var value = $("select#addBuyCountE").val();
		if(value == ""){
			$("#addBuyCountEText").val("");
			$("#addBuyCountEText").attr("readonly","readonly");
		}else{
			$("#addBuyCountEText").removeAttr("readonly");
		}
	});
	
	$("#addWeightType").change(function(){
		var value = $("#addWeightType").val();
		if(value == "" || value == "SR"){
			$("#addWeightB")[0].style.display="none";
			$("#addWeightText")[0].style.display="none";
			$("#addWeightText").attr("readonly","readonly");
			$("#addWeightBText")[0].style.display="none";
			$("#addWeightEText")[0].style.display="none";
			$("#addWeightB").val("");
			$("#addWeightText").val("");
			$("#addWeightBText").val("");
			$("#addWeightEText").val("");
		}else if(value == "NOTRANGE"){
			$("#addWeightB")[0].style.display="";
			$("#addWeightText")[0].style.display="";
			$("#addWeightBText")[0].style.display="none";
			$("#addWeightEText")[0].style.display="none";
			$("#addWeightBText").val("");
			$("#addWeightEText").val("");
		}else if(value == "RANGE"){
			$("#addWeightBText")[0].style.display="";
			$("#addWeightEText")[0].style.display="";
			$("#addWeightB")[0].style.display="none";
			$("#addWeightText")[0].style.display="none";
			$("#addWeightText").attr("readonly","readonly");
			$("#addWeightB").val("");
			$("#addWeightText").val("");
		}else{
			$("#addWeightB")[0].style.display="none";
			$("#addWeightText")[0].style.display="none";
			$("#addWeightText").attr("readonly","readonly");
			$("#addWeightBText")[0].style.display="none";
			$("#addWeightEText")[0].style.display="none";
			$("#addWeightB").val("");
			$("#addWeightText").val("");
			$("#addWeightBText").val("");
			$("#addWeightEText").val("");
		}
	});
	$("#addAmountType").change(function(){
		var value = $("#addAmountType").val();
		if(value == "" || value == "SR"){
			$("#addAmountB")[0].style.display="none";
			$("#addAmountText")[0].style.display="none";
			$("#addAmountText").attr("readonly","readonly");
			$("#addAmountBText")[0].style.display="none";
			$("#addAmountEText")[0].style.display="none";
			$("#addAmountB").val("");
			$("#addAmountText").val("");
			$("#addAmountBText").val("");
			$("#addAmountEText").val("");
		}else if(value == "NOTRANGE"){
			$("#addAmountB")[0].style.display="";
			$("#addAmountText")[0].style.display="";
			$("#addAmountBText")[0].style.display="none";
			$("#addAmountEText")[0].style.display="none";
			$("#addAmountBText").val("");
			$("#addAmountEText").val("");
		}else if(value == "RANGE"){
			$("#addAmountBText")[0].style.display="";
			$("#addAmountEText")[0].style.display="";
			$("#addAmountB")[0].style.display="none";
			$("#addAmountText")[0].style.display="none";
			$("#addAmountText").attr("readonly","readonly");
			$("#addAmountB").val("");
			$("#addAmountText").val("");
		}else{
			$("#addAmountB")[0].style.display="none";
			$("#addAmountText")[0].style.display="none";
			$("#addAmountText").attr("readonly","readonly");
			$("#addAmountBText")[0].style.display="none";
			$("#addAmountEText")[0].style.display="none";
			$("#addAmountB").val("");
			$("#addAmountText").val("");
			$("#addAmountBText").val("");
			$("#addAmountEText").val("");
		}
	});
	$("#addBuyCountType").change(function(){
		var value = $("#addBuyCountType").val();
		if(value == "" || value == "SR"){
			$("#addBuyCountB")[0].style.display="none";
			$("#addBuyCountText")[0].style.display="none";
			$("#addBuyCountText").attr("readonly","readonly");
			$("#addBuyCountBText")[0].style.display="none";
			$("#addBuyCountEText")[0].style.display="none";
			$("#addBuyCountB").val("");
			$("#addBuyCountText").val("");
			$("#addBuyCountBText").val("");
			$("#addBuyCountEText").val("");
		}else if(value == "NOTRANGE"){
			$("#addBuyCountB")[0].style.display="";
			$("#addBuyCountText")[0].style.display="";
			$("#addBuyCountBText")[0].style.display="none";
			$("#addBuyCountEText")[0].style.display="none";
			$("#addBuyCountBText").val("");
			$("#addBuyCountEText").val("");
		}else if(value == "RANGE"){
			$("#addBuyCountBText")[0].style.display="";
			$("#addBuyCountEText")[0].style.display="";
			$("#addBuyCountB")[0].style.display="none";
			$("#addBuyCountText")[0].style.display="none";
			$("#addBuyCountText").attr("readonly","readonly");
			$("#addBuyCountB").val("");
			$("#addBuyCountText").val("");
		}else{
			$("#addBuyCountB")[0].style.display="none";
			$("#addBuyCountText")[0].style.display="none";
			$("#addBuyCountText").attr("readonly","readonly");
			$("#addBuyCountBText")[0].style.display="none";
			$("#addBuyCountEText")[0].style.display="none";
			$("#addBuyCountB").val("");
			$("#addBuyCountText").val("");
			$("#addBuyCountBText").val("");
			$("#addBuyCountEText").val("");
		}
	});
})
function showAddWindow(){
	$('#addFormDiv').modal('show');
	/* var data = $('#addFormDiv').html();
	layer.open({
		  type: 1,
		  title: '新增配送商服务数据',
		  skin: 'layui-layer-rim', //样式类名
		  anim: 2,
		  area: ['1000px', '450px'], //宽高
		  shadeClose: false, //开启遮罩关闭
		  content: data
		});  */
}

function update(id){
	$.ajax({
        type: "GET",
        url: contextPath+"/distribution/showUpdateWindow",
        data: {id},
        cache: false,
        timeout: 600000,
        success: function (data) {
//        	layer.open({
//      		  type: 1,
//      		  title: '更新配送商服务数据',
//      		  skin: 'layui-layer-rim', //样式类名
//      		  anim: 2,
//      		  area: ['1000px', '450px'], //宽高
//      		  shadeClose: false, //开启遮罩关闭
//      		  content: data
//      		});
        	$("#updateDiv").html(data);
        	$("#updateDiv").modal("show");
        },
        error: function (jqXHR, textStatus, errorThrown) {
        	alert("error");
        	alert(jqXHR.responseText);
        }
    });
}

function deleteDistributions(){
	var idArray = [];
	$('input[name="chk_list"]:checked').each(function(){ 
		idArray.push($(this).val()); 
		});
	if(idArray.length == 0){
		alert("请最少选择一条数据!!!");
		return ;
	}
	var ids = idArray.toString();
	if(confirm("该操作不可恢复!确认删除数据吗?")){
		$.ajax({
	        type: "POST",
	        url: contextPath+"/distribution/delete",
	        data: {ids},
	        cache: false,
	        timeout: 600000,
	        success: function (data) {
	        	alert(data.message);
	        	window.location.href=contextPath+"/distribution";
	        },
	        error: function (jqXHR, textStatus, errorThrown) {
	        	alert("error");
	        	alert(jqXHR.responseText);
	        }
	    });
	}
	
}

function showUpdateWindow(){
	var ids = [];
	$('input[name="chk_list"]:checked').each(function(){ 
		ids.push($(this).val()); 
		});
	if(ids.length>1){
		alert("请勿选择多项数据!");
		return ;
	}
	if(ids.length == 0){
		alert("没有任何数据选中!");
		return ;
	}
	var id= ids[0]
	$.ajax({
        type: "GET",
        url: "/distribution/showUpdateWindow",
        data: {id},
        cache: false,
        timeout: 600000,
        success: function (data) {
//        	 layer.open({
//        		  type: 1,
//        		  title: '更新配送商服务数据',
//        		  skin: 'layui-layer-rim', //样式类名
//        		  anim: 2,
//        		  area: ['1000px', '450px'], //宽高
//        		  shadeClose: false, //开启遮罩关闭
//        		  content: data
//        		}); 
        	$("#updateDiv").html(data);
        	$("#updateDiv").modal("show");
        },
        error: function (jqXHR, textStatus, errorThrown) {
        	alert("error");
        	alert(jqXHR.responseText);
        }
    });
}

$("#chk_all").click(function(){//全选、取消全选的事件  
	console.log( $("input[type='checkbox']"))	
	 if(this.checked){    
       $("input[name='chk_list']").prop("checked",true);	 
    }else{    
       $("input[name='chk_list']").prop("checked",false);
    }    
});

function setSelectAll(){  
    //当没有选中某个子复选框时，SelectAll取消选中  
    console.log("c");
    if (!$("input[name='chk_list']").checked) {  
    	console.log("aaa");
        $("#chk_all").prop("checked", false);  
    }  
    var chsub = $("input[type='checkbox'][id='chk_list']").length; //获取subcheck的个数  
    var checkedsub = $("input[type='checkbox'][id='chk_list']:checked").length; //获取选中的subcheck的个数  
    if (checkedsub == chsub) {  
        $("#chk_all").prop("checked", true);  
    }  
}

$(function(){
	/*$(".ui.dropdown").dropdown();*/
})
function resetQueryForm(){
	$("#queryForm").form('clear');
}

//新增服务数据校验
function addDistribution(){
	$("#messageList").html("");
	var isOk = true;
	
	var distriCarrierCode = $("#addDistriCarrierCode").val();
	var distriIsPickUp = $("#distriIsPickUp").val();
	var distriTypeCheckeds = [];
	var distriPaymentCheckeds = [];
	var distriPropertiesCheckeds = [];
	
	$('input[name="distriType"]:checked').each(function(){ 
		distriTypeCheckeds.push($(this).val()); 
	});
	$('input[name="distriPayment"]:checked').each(function(){ 
		distriPaymentCheckeds.push($(this).val()); 
	});
	$('input[name="distriProperties"]:checked').each(function(){ 
		distriPropertiesCheckeds.push($(this).val()); 
	});
	
	var distriType = distriTypeCheckeds.toString();
	var distriPayment = distriPaymentCheckeds.toString();
	var distriProperties = distriPropertiesCheckeds.toString();
	
	var distriWeightType = $("#addWeightType").val();
	var distriAmountType = $("#addAmountType").val();
	var distriBuyCountType = $("#addBuyCountType").val();
	var distriStopTime = $("#addDistriStopTime").val();
	
	var	distriWeightOperator = null;
	var distriWeight = null;
	var distriWeightBegin = null;
	var distriWeightEnd = null;
	
	var	distriBuyCountOperator = null;
	var distriBuyCount = null;
	var distriBuyCountBegin = null;
	var distriBuyCountEnd = null;
	
	var	distriAmountOperator = null;
	var distriAmount = null;
	var distriAmountBegin = null;
	var distriAmountEnd = null;
	
	
	if(distriCarrierCode == "" || distriCarrierCode == null){
		isOk =false;
		$("#messageList").append("<li>配送商必选！</li>");
	}
	if(distriIsPickUp =="" || distriIsPickUp == null){
		isOk = false;
		$("#messageList").append("<li>请选择是否支持上门取件！</li>");
	}
	
	if(distriType.length == 0 || distriType == null){
		$("#messageList").append("<li>请选择配送方式！</li>");
	}
	if(distriPayment.length == 0 || distriPayment == null){
		$("#messageList").append("<li>请选择支付方式！</li>");
	}
	if(distriProperties.length == 0 || distriProperties == null){
		$("#messageList").append("<li>请选择配送属性！</li>");
	}
	
	if(distriWeightType == "" || distriWeightType == null){
		isOk = false;
		$("#messageList").append("<li>请选择重量！</li>");
	}else if(distriWeightType == "RANGE"){
		 var weightBText = $("#addWeightBText").val();
		 var weightEText = $("#addWeightEText").val();
		 if(weightBText == "" || weightBText == null || weightEText == "" || weightEText == null || parseFloat(weightBText) > parseFloat(weightEText)){
			 isOk = false;
			 $("#messageList").append("<li>重量区间不能为空或前区间大于后区间!</li>");
		 }else{
			 distriWeightBegin = weightBText;
			 distriWeightEnd = weightEText;
		 }
	}else if(distriWeightType == "NOTRANGE" ){
		var weightB = $("#addWeightB").val();
		if(weightB == "" || weightB == null){
			isOk = false;
			$("#messageList").append("<li>请选择非区间重量的运算符!</li>");
		}else{
			var weight = $("#addWeightText").val();
			if(weight == "" || weight == null){
				isOk = false;
				$("#messageList").append("<li>请输入非区间重量的值!</li>");
			}else{
				distriWeightOperator = weightB;
				distriWeight = weight;
			}
		}
	}	
		
	if(distriAmountType == "" || distriAmountType == null){
		isOk = false;
		$("#messageList").append("<li>请选择金额！</li>");
	}else if(distriAmountType == "RANGE"){
		 var amountBText = $("#addAmountBText").val();
		 var amountEText = $("#addAmountEText").val();
		 if(amountBText == "" || amountBText == null || amountEText == "" || amountEText == null || parseFloat(amountBText) > parseFloat(amountEText)){
			 isOk = false;
			 $("#messageList").append("<li>金额区间不能为空或前区间大于后区间!</li>");
		 }else{
			 distriAmountBegin = amountBText;
			 distriAmountEnd = amountEText;
		 }
	}else if(distriAmountType == "NOTRANGE" ){
		var amountB = $("#addAmountB").val();
		if(amountB == "" || amountB == null){
			isOk = false;
			$("#messageList").append("<li>请选择非区间金额的运算符!</li>");
		}else{
			var amount = $("#addAmountText").val();
			if(amount == "" || amount == null){
				isOk = false;
				$("#messageList").append("<li>请输入非区间金额的值!</li>");
			}else{
				distriAmountOperator = amountB;
				distriAmount = amount;
			}
		}
	}
	
	if(distriBuyCountType == "" || distriBuyCountType == null){
		isOk = false;
		$("#messageList").append("<li>请选择次数！</li>");
	}else if(distriBuyCountType == "RANGE"){
		 var buyCountBText = $("#addBuyCountBText").val();
		 var buyCountEText = $("#addBuyCountEText").val();
		 if(buyCountBText == "" || buyCountBText == null || buyCountEText == "" || buyCountEText == null || parseInt(buyCountBText) > parseInt(buyCountEText)){
			 isOk = false;
			 $("#messageList").append("<li>次数区间不能为空或前区间大于后区间!</li>");
		 }else{
			 distriBuyCountBegin = buyCountBText;
			 distriBuyCountEnd =  buyCountEText;
		 }
	}else if(distriBuyCountType == "NOTRANGE" ){
		var buyCountB = $("#addBuyCountB").val();
		if(buyCountB == "" || buyCountB == null){
			isOk = false;
			$("#messageList").append("<li>请选择非区间次数的运算符!</li>");
		}else{
			var buyCount = $("#addBuyCountText").val();
			if(buyCount == "" || buyCount == null){
				isOk = false;
				$("#messageList").append("<li>请输入非区间次数的值!</li>");
			}else{
				distriBuyCountOperator = buyCountB;
				distriBuyCount = buyCount;
			}
		}
	}
	
	var strs = distriStopTime.split(":");
	if(strs == "" || strs == null || strs == undefined || strs.length >2 ||  strs.length == 0){
		isOk = false;
		$("#messageList").append("<li>请输入24小时制的小时分钟截单时间,例如:17:00;或截单时间不能为空!</li>");
	}
	
	if(isOk){
		$("#validationMessage")[0].style.display="none";
		 $.ajax({
	        type: "POST",
	        url: contextPath+"/distribution/validation",
	        data: {
	        	distriCarrierCode,
	        	distriIsPickUp,
	        	distriType,
	        	distriPayment,
	        	distriProperties,
	        	distriWeightType,
	        	distriAmountType,
	        	distriBuyCountType,
	        	distriStopTime,
	        	distriWeightOperator,
	        	distriWeight,
	        	distriWeightBegin,
	        	distriWeightEnd,
	        	distriBuyCountOperator,
	        	distriBuyCount,
	        	distriBuyCountBegin,
	        	distriBuyCountEnd,
	        	distriAmountOperator,
	        	distriAmount,
	        	distriAmountBegin,
	        	distriAmountEnd
	       		},
	        cache: false,
	        timeout: 600000,
	        success: function (data) {
	        	if(data.status == 500){
	        		$("#messageList").append("<li>新增服务数据已存在!请重新输入服务数据!</li>");
	        		$("#validationMessage")[0].style.display="";
	        	}else if( data.status == 200){
	        		$("#addForm").submit();
	        	}else{
	        		$("#messageList").append("<li>新增服务数据发生未知错误!请稍后重试!</li>");
	        	}
	        },
	        error: function (jqXHR, textStatus, errorThrown) {
	        	alert("error");
	        	alert(jqXHR.responseText);
	        }
	    }); 
	}else{
		$("#validationMessage")[0].style.display="";
	}
	
}

